﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;

namespace MINERP.COM
{
    public class MnemonicCode
    {
        public MnemonicCode()
        {
            // 
            // todo: 在此处添加构造函数逻辑 
            // 
        }
        public static string chinesecap(string chinesestr)
        {

            string capstr = "";
            byte[] zw = new byte[2];
            long chinesestr_int;
            string charstr, chinastr = "";
            for (int i = 0; i <= chinesestr.Length - 1; i++)
            {
                charstr = chinesestr.Substring(i, 1).ToString();
                zw = Encoding.Default.GetBytes(charstr);
                // 得到汉字符的字节数组 
                if (zw.Length == 2)
                {
                    int i1 = (short)(zw[0]);
                    int i2 = (short)(zw[1]);
                    chinesestr_int = i1 * 256 + i2;
                    //table of the constant list 
                    // a; //45217..45252 
                    // b; //45253..45760 
                    // c; //45761..46317 
                    // d; //46318..46825 
                    // e; //46826..47009 
                    // f; //47010..47296 
                    // g; //47297..47613 

                    // h; //47614..48118 
                    // j; //48119..49061 
                    // k; //49062..49323 
                    // l; //49324..49895 
                    // m; //49896..50370 
                    // n; //50371..50613 
                    // o; //50614..50621 
                    // p; //50622..50905 
                    // q; //50906..51386 

                    // r; //51387..51445 
                    // s; //51446..52217 
                    // t; //52218..52697 
                    //没有u,v 
                    // w; //52698..52979 
                    // x; //52980..53640 
                    // y; //53689..54480 
                    // z; //54481..55289 

                    if ((chinesestr_int >= 45217) && (chinesestr_int <= 45252))
                    {
                        chinastr = "A";
                    }
                    else if ((chinesestr_int >= 45253) && (chinesestr_int <= 45760))
                    {
                        chinastr = "b";
                    }
                    else if ((chinesestr_int >= 45761) && (chinesestr_int <= 46317))
                    {
                        chinastr = "C";

                    }
                    else if ((chinesestr_int >= 46318) && (chinesestr_int <= 46825))
                    {
                        chinastr = "D";
                    }
                    else if ((chinesestr_int >= 46826) && (chinesestr_int <= 47009))
                    {
                        chinastr = "E";
                    }
                    else if ((chinesestr_int >= 47010) && (chinesestr_int <= 47296))
                    {
                        chinastr = "F";
                    }
                    else if ((chinesestr_int >= 47297) && (chinesestr_int <= 47613))
                    {
                        chinastr = "G";
                    }
                    else if ((chinesestr_int >= 47614) && (chinesestr_int <= 48118))
                    {

                        chinastr = "H";
                    }

                    else if ((chinesestr_int >= 48119) && (chinesestr_int <= 49061))
                    {
                        chinastr = "J";
                    }
                    else if ((chinesestr_int >= 49062) && (chinesestr_int <= 49323))
                    {
                        chinastr = "K";
                    }
                    else if ((chinesestr_int >= 49324) && (chinesestr_int <= 49895))
                    {
                        chinastr = "L";
                    }
                    else if ((chinesestr_int >= 49896) && (chinesestr_int <= 50370))
                    {
                        chinastr = "M";
                    }

                    else if ((chinesestr_int >= 50371) && (chinesestr_int <= 50613))
                    {
                        chinastr = "N";

                    }
                    else if ((chinesestr_int >= 50614) && (chinesestr_int <= 50621))
                    {
                        chinastr = "O";
                    }
                    else if ((chinesestr_int >= 50622) && (chinesestr_int <= 50905))
                    {
                        chinastr = "P";

                    }
                    else if ((chinesestr_int >= 50906) && (chinesestr_int <= 51386))
                    {
                        chinastr = "Q";

                    }

                    else if ((chinesestr_int >= 51387) && (chinesestr_int <= 51445))
                    {
                        chinastr = "R";
                    }
                    else if ((chinesestr_int >= 51446) && (chinesestr_int <= 52217))
                    {
                        chinastr = "S";
                    }
                    else if ((chinesestr_int >= 52218) && (chinesestr_int <= 52697))
                    {
                        chinastr = "T";
                    }
                    else if ((chinesestr_int >= 52698) && (chinesestr_int <= 52979))
                    {
                        chinastr = "W";
                    }
                    else if ((chinesestr_int >= 52980) && (chinesestr_int <= 53640))
                    {
                        chinastr = "X";
                    }
                    else if ((chinesestr_int >= 53689) && (chinesestr_int <= 54480))
                    {
                        chinastr = "Y";
                    }
                    else if ((chinesestr_int >= 54481) && (chinesestr_int <= 55289))
                    {
                        chinastr = "Z";
                    }

                }
                else
                {
                    capstr = chinesestr;
                    break;
                }
                capstr = capstr + chinastr;
            }

            return capstr;
        } 
    }
}
